<template>
  <div class="mybox w">
    <p class="title">文件列表</p>
    <div class="docMain">
      <h3>
        文件名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;上传日期
      </h3>
      <ul>
        <li v-for="(i, index) in files" :key="index" >
          <p class="icon"><img src="../assets/img/文件.png" alt=""></p>
          <a @click="downloadFile(i.fileName)">{{ i.fileName }}</a>
          <span class="time">{{ i.uploadTime }}</span>
        </li>
<!--        <li>-->
<!--          <p class="icon"><img src="../assets/img/文件.png" alt=""></p>-->
<!--          <a href="">{{ documentName }}</a>-->
<!--          <span class="time">{{ updateTime }}</span>-->
<!--        </li>-->
<!--        <li>-->
<!--          <p class="icon"><img src="../assets/img/文件.png" title="这是一个标签"></p>-->
<!--          <a href="">{{ documentName }}</a>-->
<!--          <span class="time">{{ updateTime }}</span>-->
<!--        </li>-->
<!--        <li>-->
<!--          <p class="icon"><img src="../assets/img/文件.png" alt=""></p>-->
<!--          <a href="">{{ documentName }}</a>-->
<!--          <span class="time">{{ updateTime }}</span>-->
<!--        </li>-->
<!--        <li>-->
<!--          <p class="icon"><img src="../assets/img/文件.png" alt=""></p>-->
<!--          <a href="">{{ documentName }}</a>-->
<!--          <span class="time">{{ updateTime }}</span>-->

<!--        </li>-->
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      pagination: {//分页相关模型数据
        currentPage: 1,//当前页码
        pageSize: 10,//每页显示的记录数
        total: 0,//总记录数
        title: "",//查询条件
      },
      files:[],
      documentName: '关于成都市天气最新报告',
      updateTime: '2023年10月10日'
    }
  },
  methods:{
    //获取所有用户信息
    getAll() {
      //发送异步请求
      this.$axios.get("/file/file/fileList?curpage=" + this.pagination.currentPage + "&pagesize=" + this.pagination.pageSize).then((res) => {
        // console.log("filr!!!")
        this.pagination.total = res.data.data.total;
        console.log("filr!!w!")
        res.data.data.records.forEach(function(item,index,self){
          self[index].uploadTime=item.uploadTime.substr(0,10)
        })
        this.files = res.data.data.records;
        console.log(this.files)

        // console.log(res.data.data.records[0].ddate);
      });
    },
    downloadFile(fileName){
      let link = document.createElement('a');
      link.style.display = 'none';
      // this.src=url+"/article/article/download/"+res.data.data.pic+"?filePath=articles&fileName="+ res.data.data.pic;

      link.href = VUE_APP_URL.BASE_URL+ '/file/file/download/'+fileName+'?filePath=file&fileName='+fileName;

      document.body.appendChild(link);
      link.click();
    }
  },
  mounted() {
    this.getAll();
  }
}
</script>

<style scoped>
* {
  padding: 0;
  margin: 0;
}

.mybox {
  width: 300px;
  height: 385px;
  background-color: rgb(255, 255, 255);
}

.title {
  text-align: left;
  color: rgb(40, 40, 40);
  padding: 0 15px;
  height: 40px;
  line-height: 40px;
  font-size: large;
  margin-bottom: 10px;
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  background-color: #113669;
}

.docMain {
  height: 330px;
  background-color: rgb(255, 255, 255);
}

.docMain h3 {
  padding: 0 40px;
  padding-bottom: 6px;
  padding-right: 0;
  margin: 0 10px;
  font-size: 14px;
  color: #000;
  margin-top: 15px;
  border-bottom: 1px solid #dfdfdf;
}

.docMain ul {
  padding: 20px 20px;
  padding-top: 15px;
  /* padding-left: 0/; */
}

.docMain ul li p {
  margin-right: 15px;
}

.docMain ul li {
  margin-bottom: 30px;
}

.docMain ul li a {
  font-size: 12px;
  display: inline-block;
  width: 110px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 15px;
}

.docMain ul li a:hover {
  color: #000;
}

.docMain ul li:hover {
  background-color: aliceblue;
  color: #000;
}

.docMain ul li span {
  vertical-align: middle;
  font-size: 12px;
}

.docMain ul li span:hover {
  color: #000;
}

.icon {
  display: inline-block;
  width: 30px;
  margin-right: 20px;
}

.icon img {
  width: 100%
}

/* color palette from <https://github.com/vuejs/theme> */
:root {
  --vt-c-white: #ffffff;
  --vt-c-white-soft: #f8f8f8;
  --vt-c-white-mute: #f2f2f2;

  --vt-c-black: #181818;
  --vt-c-black-soft: #222222;
  --vt-c-black-mute: #282828;

  --vt-c-indigo: #2c3e50;

  --vt-c-divider-light-1: rgba(60, 60, 60, 0.29);
  --vt-c-divider-light-2: rgba(60, 60, 60, 0.12);
  --vt-c-divider-dark-1: rgba(84, 84, 84, 0.65);
  --vt-c-divider-dark-2: rgba(84, 84, 84, 0.48);

  --vt-c-text-light-1: var(--vt-c-indigo);
  --vt-c-text-light-2: rgba(60, 60, 60, 0.66);
  --vt-c-text-dark-1: var(--vt-c-white);
  --vt-c-text-dark-2: rgba(235, 235, 235, 0.64);
}

/* semantic color variables for this project */
:root {
  --color-background: var(--vt-c-white);
  --color-background-soft: var(--vt-c-white-soft);
  --color-background-mute: var(--vt-c-white-mute);

  --color-border: var(--vt-c-divider-light-2);
  --color-border-hover: var(--vt-c-divider-light-1);

  --color-heading: var(--vt-c-text-light-1);
  --color-text: var(--vt-c-text-light-1);

  --section-gap: 160px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-background: var(--vt-c-black);
    --color-background-soft: var(--vt-c-black-soft);
    --color-background-mute: var(--vt-c-black-mute);

    --color-border: var(--vt-c-divider-dark-2);
    --color-border-hover: var(--vt-c-divider-dark-1);

    --color-heading: var(--vt-c-text-dark-1);
    --color-text: var(--vt-c-text-dark-2);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  position: relative;
  font-weight: normal;
}

body {
  min-height: 100vh;
  color: var(--color-text);
  background: var(--color-background);
  transition: color 0.5s, background-color 0.5s;
  line-height: 1.6;
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
    Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  font-size: 15px;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 把我们所有标签的内外边距清零 */
* {
  margin: 0;
  padding: 0;
  /* CSS3盒子模型 */
  box-sizing: border-box;
}

/* em 和 i 斜体的文字不倾斜 */
em,
i {
  font-style: normal
}

/* 去掉li 的小圆点 */
li {
  list-style: none
}

img {
  /* border 0 照顾低版本浏览器 如果 图片外面包含了链接会有边框的问题 */
  border: 0;
  /* 取消图片底侧有空白缝隙的问题 */
  vertical-align: middle
}

button {
  /* 当我们鼠标经过button 按钮的时候，鼠标变成小手 */
  cursor: pointer
}

input:focus {
  outline: none;
}


a {
  color: #666;
  text-decoration: none
}

a:hover {
  color: #457e4c
}

button,
input {
  /* "\5B8B\4F53" 就是宋体的意思 这样浏览器兼容性比较好 */
  font-family: Microsoft YaHei, Heiti SC, tahoma, arial, Hiragino Sans GB, "\5B8B\4F53", sans-serif
}

/* 隐藏浏览器右侧的滚动条 */
body {
  overflow-y: scroll;
  scrollbar-width: none;
  /* Firefox */
  -ms-overflow-style: none;
  /* Internet Explorer 10+ */
}

/* Chrome 和 Safari */
::-webkit-scrollbar {
  width: 0;
  height: 0;
}


body {
  /* CSS3 抗锯齿形 让文字显示的更加清晰 */
  -webkit-font-smoothing: antialiased;
  background-color: #fff;
  font: 12px/1.5 Microsoft YaHei, Heiti SC, tahoma, arial, Hiragino Sans GB, "\5B8B\4F53", sans-serif;
  color: #666
}

.hide,
.none {
  display: none
}

/* 清除浮动 */
.clearfix:after {
  visibility: hidden;
  clear: both;
  display: block;
  content: ".";
  height: 0
}

.clearfix {
  *zoom: 1
}
</style>
